package com.pokeoffice.client;

import java.awt.Component;
import java.sql.Connection;

import javax.swing.JFrame;

/**
 * The Class State.
 *
 * @author Kyle Davis
 * 
 * (Pattern: State) Represents the state the client is in
 */
public class State {

	/** The connection. */
	private Connection connection;
	
	/** The screen. */
	private JFrame screen = null;
	
	/**
	 * Instantiates a new state.
	 */
	public State() {
		screen = new JFrame();
		screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	/**
	 * Adds the.
	 *
	 * @param c the c
	 */
	public void add(Component c) {
		screen.add(c);
	}
	
	/**
	 * Removes the.
	 *
	 * @param c the c
	 */
	public void remove(Component c) {
		screen.remove(c);
	}
	
	/**
	 * Clear.
	 */
	public void clear() {
		screen.setVisible(false);
		screen = new JFrame();
		screen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	/**
	 * Display.
	 */
	public void display() {
		screen.pack();
		screen.setVisible(true);
	}
	
	/**
	 * Hide.
	 */
	public void hide() {
		screen.pack();
		screen.setVisible(false);
	}

	/**
	 * Sets the connection.
	 *
	 * @param connection the new connection
	 */
	public void setConnection(Connection connection) {
		this.connection = connection;
	}

	/**
	 * Gets the connection.
	 *
	 * @return the connection
	 */
	public Connection getConnection() {
		return connection;
	}

	/**
	 * Sets the screen.
	 *
	 * @param screen the new screen
	 */
	public void setScreen(JFrame screen) {
		this.screen = screen;
	}

	/**
	 * Gets the screen.
	 *
	 * @return the screen
	 */
	public JFrame getScreen() {
		return screen;
	}
}
